#ifndef __BASE_EGL__H__
#define __BASE_EGL__H__

#ifdef __ANDROID__
#include <EGL/egl.h>
#include <EGL/eglext.h>
#include <EGL/eglplatform.h>
#include "jni_utils.h"
#endif

#include <memory>
#include <functional>

namespace simple_renderer{

class BaseEgl{

public:
    BaseEgl():_on_draw(nullptr){}
    virtual ~BaseEgl(){}

    virtual int InitGLEnv() = 0;
    virtual int Release() = 0;
//#ifdef __ANDROID__
    virtual int SetAndroidView(std::shared_ptr<JavaGlobalRef<jobject>> frame_window_ref) = 0;
    virtual int ResetAndroidView() = 0;
//#endif

    virtual int CreateSurface() = 0;
    virtual int DestorySurface() = 0;

    virtual int MakeCurrent() = 0;
    virtual int EGLSwap() = 0;
    virtual int DetachCurrent() = 0;

    virtual bool IsEglValidate() = 0;
    virtual bool HasContext() = 0;

    virtual int SetSurfaceSize(int w, int h) = 0;

    virtual bool IsEnvReleased() = 0;

    virtual int GetWidth() = 0;
    virtual int GetHeight() = 0;

    virtual void SetOnDrawCallback(std::function<void()> on_draw){
        _on_draw = on_draw;
    };

protected:
    std::function<void()> _on_draw;
};

}
#endif